package com.bsdsma.fengheguaiapp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bsdsma.fengheguaiapp.dto.RoomTypeDto;
import com.bsdsma.fengheguaiapp.entity.ServiceInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.bsdsma.fengheguaiapp.dto.DataGroupByDateDto;

import java.util.Date;
import java.util.List;

/**
* 入住情况 Mybatis数据库操作接口
*/
@Mapper
public interface ServiceInfoMapper extends BaseMapper<ServiceInfo> {

    @Select("select DATE_FORMAT(ct, '%Y-%m-%d') `day`, count(1) num from serviceInfo where ct >= #{beginDate} and ct <= #{endDate} group by `day` order by `day`;")
    List<DataGroupByDateDto> countByDay(@Param(value = "beginDate") Date beginDate, @Param(value = "endDate") Date endDate);

    /**
     * 查询所有不重复的房间类型
     */
    /*@Select("SELECT DISTINCT room_type FROM roominfo")
    List<String> selectRoomTypes();*/
    @Select("SELECT MIN(id) as id, room_type as type FROM roominfo GROUP BY room_type")
    List<RoomTypeDto> selectRoomTypes();
}